import React, { Component } from 'react'
import axios from "axios"
 class pullDeatl extends Component {
   state = {
       ind:0,
       arr:[] 
   }
   componentDidMount(){
        axios.get("/list1").then(res=>{
            let arr1 = res.data.list
            let brr =  arr1.filter((item,index)=>{
                 return index == this.props.match.params.id
            })
            console.log(brr,11111);
            this.setState({
                arr:brr
            })
        })
   }
  render() {
    // 如果没有明确要求，就按以前得列表跳转详情，如果要求了，就这样，将参数取下来fiter过滤出需要得详情
    console.log( this.props.match.params.id,11111) // 动态路由取参数
    console.log(this.state.arr,44444);
    return (
      <div>
          {
              this.state.arr&&this.state.arr.length? this.state.arr.map((item,index)=>{
                  return <div key={index}>
                      <span>{item.name}</span>
                      <img src={item.img} alt="" />
                  </div>
              }):"暂无数据"
          }
      </div>
    )
  }
}

export default pullDeatl